home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / script-fu / scripts / glossy.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2003-02-27  |  9.2 KB  |  240 lines

  1. ; glossy-patterned-shadowed-and-bump-mapped-logo
  2. ; creates anything you can create with it :)
  3. ; (use it wisely, use it in peace...) 
  4. ;
  5. ; The GIMP -- an image manipulation program
  6. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  7. ;
  8. ; glossy gives a glossy outlook to your fonts (unlogical name, isn't it?)
  9. ; Copyright (C) 1998 Hrvoje Horvat
  10. ;
  11. ; This program is free software; you can redistribute it and/or modify
  12. ; it under the terms of the GNU General Public License as published by
  13. ; the Free Software Foundation; either version 2 of the License, or
  14. ; (at your option) any later version.
  15. ;
  16. ; This program is distributed in the hope that it will be useful,
  17. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ; GNU General Public License for more details.
  20. ;
  21. ; You should have received a copy of the GNU General Public License
  22. ; along with this program; if not, write to the Free Software
  23. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. (define (apply-glossy-logo-effect img
  26.                   logo-layer
  27.                   blend-gradient-text
  28.                   blend-gradient-outline
  29.                   grow-size
  30.                   bg-color
  31.                   use-pattern-text
  32.                   pattern-text
  33.                   use-pattern-outline
  34.                   pattern-outline
  35.                   use-pattern-overlay
  36.                   pattern-overlay
  37.                   noninteractive
  38.                   shadow-toggle
  39.                   s-offset-x
  40.                   s-offset-y)
  41.   (let* ((width (car (gimp-drawable-width logo-layer)))
  42.          (height (car (gimp-drawable-height logo-layer)))
  43.          (posx (- (car (gimp-drawable-offsets logo-layer))))
  44.          (posy (- (cadr (gimp-drawable-offsets logo-layer))))
  45.          (bg-layer (car (gimp-layer-new img width height RGB_IMAGE "Background" 100 NORMAL)))
  46.          (grow-me (car (gimp-layer-copy logo-layer TRUE)))
  47.  
  48.          (old-gradient (car (gimp-gradients-get-active)))
  49.          (old-patterns (car (gimp-patterns-get-pattern)))
  50.          (old-fg (car (gimp-palette-get-foreground)))
  51.          (old-bg (car (gimp-palette-get-background))))
  52.  
  53.     (script-fu-util-image-resize-from-layer img logo-layer)
  54.     (gimp-layer-set-name grow-me "Grow-me")
  55.     (gimp-image-add-layer img grow-me 1)
  56.     (gimp-layer-translate grow-me posx posy)
  57.     (gimp-image-add-layer img bg-layer 2)
  58.  
  59.     (gimp-palette-set-background bg-color)
  60.     (gimp-selection-all img)
  61.     (gimp-bucket-fill bg-layer BG-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  62.     (gimp-selection-none img)
  63.     (gimp-palette-set-background old-bg)
  64.  
  65.     (gimp-selection-layer-alpha logo-layer)
  66.  
  67. ; if we are going to use transparent gradients for text, we will (maybe) need to uncomment this
  68. ; this clears black letters first so you don't end up with black where the transparent should be
  69. ;    (gimp-edit-clear img logo-layer)
  70.  
  71.     (if (= use-pattern-text TRUE)
  72.       (begin
  73.         (gimp-patterns-set-pattern pattern-text)
  74.         (gimp-bucket-fill logo-layer PATTERN-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  75.         (gimp-patterns-set-pattern old-patterns)))
  76.  
  77.     (if (= use-pattern-text FALSE)
  78.       (begin
  79.         (gimp-gradients-set-active blend-gradient-text)
  80.         (gimp-blend logo-layer CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 0 (+ height 5))))
  81.  
  82.     (gimp-selection-none img)
  83.  
  84.     (gimp-selection-layer-alpha grow-me)
  85.     (gimp-selection-grow img grow-size)
  86.  
  87. ; if we are going to use transparent gradients for outline, we will (maybe) need to uncomment this
  88. ; I didn't put it in the options because there are already enough settings there and anyway, transparent
  89. ; gradients will be used very rarely (if ever)
  90. ;    (gimp-edit-clear img grow-me)
  91.  
  92.     (if (= use-pattern-outline TRUE)
  93.       (begin
  94.         (gimp-patterns-set-pattern pattern-outline)
  95.         (gimp-bucket-fill grow-me PATTERN-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  96.         (gimp-patterns-set-pattern old-patterns)))
  97.  
  98.     (if (= use-pattern-outline FALSE)
  99.       (begin
  100.         (gimp-gradients-set-active blend-gradient-outline)
  101.         (gimp-blend grow-me CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 0 (+ height 5))))
  102.  
  103.     (gimp-selection-none img)
  104.  
  105.     (plug-in-bump-map noninteractive img grow-me logo-layer 110.0 45.0 3 0 0 0 0 TRUE FALSE 0)
  106.     (gimp-layer-set-mode logo-layer SCREEN)
  107.  
  108.     (if (= use-pattern-overlay TRUE)
  109.       (begin
  110.         (gimp-selection-layer-alpha grow-me)
  111.         (gimp-patterns-set-pattern pattern-overlay)
  112.         (gimp-bucket-fill grow-me PATTERN-BUCKET-FILL OVERLAY 100 0 FALSE 0 0)
  113.         (gimp-patterns-set-pattern old-patterns)
  114.         (gimp-selection-none img)))
  115.    
  116.     (if (= shadow-toggle TRUE)
  117.       (begin
  118.     (gimp-selection-layer-alpha logo-layer)
  119.     (set! dont-drop-me (car (script-fu-drop-shadow img logo-layer s-offset-x s-offset-y 15 '(0 0 0) 80 TRUE)))
  120.         (set! width (car (gimp-image-width img)))
  121.         (set! height (car (gimp-image-height img)))
  122.         (gimp-selection-none img)))
  123.  
  124.   (gimp-gradients-set-active old-gradient)
  125.   (gimp-palette-set-background old-bg)
  126.   (gimp-palette-set-foreground old-fg)))
  127.  
  128.  
  129. (define (script-fu-glossy-logo-alpha img
  130.                      logo-layer
  131.                      blend-gradient-text
  132.                      blend-gradient-outline
  133.                      grow-size
  134.                      bg-color
  135.                      use-pattern-text
  136.                      pattern-text
  137.                      use-pattern-outline
  138.                      pattern-outline
  139.                      use-pattern-overlay
  140.                      pattern-overlay
  141.                      noninteractive
  142.                      shadow-toggle
  143.                      s-offset-x
  144.                      s-offset-y)
  145.   (begin
  146.     (gimp-undo-push-group-start img)
  147.     (apply-glossy-logo-effect img logo-layer blend-gradient-text
  148.                   blend-gradient-outline grow-size bg-color
  149.                   use-pattern-text pattern-text
  150.                   use-pattern-outline pattern-outline
  151.                   use-pattern-overlay pattern-overlay
  152.                   noninteractive shadow-toggle
  153.                   s-offset-x s-offset-y)
  154.     (gimp-undo-push-group-end img)
  155.     (gimp-displays-flush)))
  156.  
  157.  
  158. (script-fu-register "script-fu-glossy-logo-alpha"
  159.                     _"<Image>/Script-Fu/Alpha to Logo/Glossy..."
  160.                     "Creates anything you can create with it :)"
  161.                     "Hrvoje Horvat (hhorvat@open.hr)"
  162.                     "Hrvoje Horvat"
  163.                     "14/04/1998"
  164.             "RGBA"
  165.                     SF-IMAGE      "Image" 0
  166.                     SF-DRAWABLE   "Drawable" 0
  167.                     SF-GRADIENT   _"Blend Gradient (Text)" "Shadows_2"
  168.                     SF-GRADIENT   _"Blend Gradient (Outline)" "Shadows_2"
  169.                     SF-ADJUSTMENT _"Outline Size" '(5 0 250 1 10 0 1)
  170.             SF-COLOR      _"Background Color" '(255 255 255)
  171.             SF-TOGGLE     _"Use Pattern for Text instead of Gradient" FALSE
  172.             SF-PATTERN    _"Pattern (Text)" "Electric Blue"
  173.             SF-TOGGLE     _"Use Pattern for Outline instead of Gradient" FALSE
  174.             SF-PATTERN    _"Pattern (Outline)" "Electric Blue"
  175.             SF-TOGGLE     _"Use Pattern Overlay" FALSE
  176.             SF-PATTERN    _"Pattern (Overlay)" "Parque #1"
  177.             SF-TOGGLE     _"Default Bumpmap Settings" TRUE
  178.             SF-TOGGLE     _"Shadow" TRUE
  179.             SF-ADJUSTMENT _"Shadow X Offset" '(8 0 100 1 10 0 1)
  180.                     SF-ADJUSTMENT _"Shadow Y Offset" '(8 0 100 1 10 0 1)
  181.             )
  182.  
  183.  
  184. (define (script-fu-glossy-logo text
  185.                    size
  186.                    font
  187.                    blend-gradient-text
  188.                    blend-gradient-outline
  189.                    grow-size
  190.                    bg-color
  191.                    use-pattern-text
  192.                    pattern-text
  193.                    use-pattern-outline
  194.                    pattern-outline
  195.                    use-pattern-overlay
  196.                    pattern-overlay
  197.                    noninteractive
  198.                    shadow-toggle
  199.                    s-offset-x
  200.                    s-offset-y)
  201.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  202.      (text-layer (car (gimp-text-fontname img -1 0 0 text 30 TRUE size PIXELS font))))
  203.     (gimp-image-undo-disable img)
  204.     (gimp-layer-set-name text-layer text)
  205.     (apply-glossy-logo-effect img text-layer blend-gradient-text
  206.                   blend-gradient-outline grow-size bg-color
  207.                   use-pattern-text pattern-text
  208.                   use-pattern-outline pattern-outline
  209.                   use-pattern-overlay pattern-overlay
  210.                   noninteractive shadow-toggle
  211.                   s-offset-x s-offset-y)
  212.     (gimp-image-undo-enable img)
  213.     (gimp-display-new img)))
  214.  
  215. (script-fu-register "script-fu-glossy-logo"
  216.                     _"<Toolbox>/Xtns/Script-Fu/Logos/Glossy..."
  217.                     "Creates anything you can create with it :)"
  218.                     "Hrvoje Horvat (hhorvat@open.hr)"
  219.                     "Hrvoje Horvat"
  220.                     "14/04/1998"
  221.                     ""
  222.                     SF-STRING     _"Text" "Galaxy"
  223.                     SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1)
  224.                     SF-FONT       _"Font" "-*-Eras-*-r-*-*-24-*-*-*-p-*-*-*"
  225.                     SF-GRADIENT   _"Blend Gradient (Text)" "Shadows_2"
  226.                     SF-GRADIENT   _"Blend Gradient (Outline)" "Shadows_2"
  227.                     SF-ADJUSTMENT _"Outline Size" '(5 0 250 1 10 0 1)
  228.             SF-COLOR      _"Background Color" '(255 255 255)
  229.             SF-TOGGLE     _"Use Pattern for Text instead of Gradient" FALSE
  230.             SF-PATTERN    _"Pattern (Text)" "Electric Blue"
  231.             SF-TOGGLE     _"Use Pattern for Outline instead of Gradient" FALSE
  232.             SF-PATTERN    _"Pattern (Outline)" "Electric Blue"
  233.             SF-TOGGLE     _"Use Pattern Overlay" FALSE
  234.             SF-PATTERN    _"Pattern (Overlay)" "Parque #1"
  235.             SF-TOGGLE     _"Default Bumpmap Settings" TRUE
  236.             SF-TOGGLE     _"Shadow" TRUE
  237.             SF-ADJUSTMENT _"Shadow X Offset" '(8 0 100 1 10 0 1)
  238.                     SF-ADJUSTMENT _"Shadow Y Offset" '(8 0 100 1 10 0 1)
  239.             )
  240.